package com.dogkr.server.entity;

import java.math.BigDecimal;
import java.text.ParseException;
import java.util.Date;

import com.sean.common.utils.DateUtils;

public class OrderServer {
    private Long id;

    private Long orderId;

    private Long valId;

    private String serverName;

    private BigDecimal serverPrice;

    private Short serverMeasure;

    private Short serverMeasureType;

    private BigDecimal serverPriceAll;

    private Date lastModifydate;

    private Date createDate;

    private Short status;

    private String remark;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getOrderId() {
        return orderId;
    }

    public void setOrderId(Long orderId) {
        this.orderId = orderId;
    }

    public Long getValId() {
        return valId;
    }

    public void setValId(Long valId) {
        this.valId = valId;
    }

    public String getServerName() {
        return serverName;
    }

    public void setServerName(String serverName) {
        this.serverName = serverName;
    }

    public BigDecimal getServerPrice() {
        return serverPrice;
    }

    public void setServerPrice(BigDecimal serverPrice) {
        this.serverPrice = serverPrice;
    }

    public Short getServerMeasure() {
        return serverMeasure;
    }

    public void setServerMeasure(Short serverMeasure) {
        this.serverMeasure = serverMeasure;
    }

    public Short getServerMeasureType() {
        return serverMeasureType;
    }

    public void setServerMeasureType(Short serverMeasureType) {
        this.serverMeasureType = serverMeasureType;
    }

    public BigDecimal getServerPriceAll() {
        return serverPriceAll;
    }

    public void setServerPriceAll(BigDecimal serverPriceAll) {
        this.serverPriceAll = serverPriceAll;
    }

    public Date getLastModifydate() {
        return lastModifydate;
    }

    public void setLastModifydate(Date lastModifydate) {
        this.lastModifydate = lastModifydate;
    }

    public Date getCreateDate() {
        return createDate;
    }

    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }

    public Short getStatus() {
        return status;
    }

    public void setStatus(Short status) {
        this.status = status;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

	public void createInit(Order order, PetServerValuation valuation) throws ParseException {
		this.serverName = valuation.getValueName();
		this.serverPrice = valuation.getValueVal();
		this.serverMeasureType = valuation.getValueType();
		this.orderId = order.getId();
		int days = DateUtils.getDays(order.getOrderStartDate(), order.getOrderEndDate());
		if(this.serverMeasureType == PetServer.ValueTypeEnum.DAY.getVal()) {
			this.serverMeasure = (short) days;
		}
		this.serverPriceAll = this.serverPrice.multiply(BigDecimal.valueOf(this.serverMeasure));
	}
}